package com.qinggeng.project.api.dto;

import com.qinggeng.project.system.domain.OrdersAddress;
import com.qinggeng.project.system.domain.UserAddress;
import lombok.Data;

@Data
public class AddOrdersInfoAddressDto {

    //地址ID
    private Long addressId;
    //地址详情
    private String addressInfo;
    //收货姓名
    private String consignee;
    //收货地区
    private String addressName;
    //收货手机号
    private String addressPhone;
    //门牌号
    private String addressHouse;
    //地址标签 1=家 2=公司 3=学校
    private Integer addressMark;
    //性别
    private String sex;

    private Float addressLng;

    private Float addressLat;

    /** 距离 */
    private Double distance;

    public static AddOrdersInfoAddressDto news(OrdersAddress ordersAddress) {
        AddOrdersInfoAddressDto dto = new AddOrdersInfoAddressDto();
        dto.setAddressId(ordersAddress.getAddressId());
        dto.setAddressInfo(ordersAddress.getAddressInfo());
        dto.setConsignee(ordersAddress.getConsignee());
        dto.setAddressName(ordersAddress.getAddressName());
        dto.setAddressPhone(ordersAddress.getAddressPhone());
        dto.setAddressMark(ordersAddress.getAddressMark());
        dto.setSex(ordersAddress.getSex());
        dto.setDistance(ordersAddress.getDistance());
        return dto;
    }


    public String getSex() {
        if (this.sex.equals("10")){
            return "先生";
        }
        if (this.sex.equals("20")){
            return "女士";
        }
        return sex;
    }

    public AddOrdersInfoAddressDto(){

    }

    public AddOrdersInfoAddressDto(UserAddress userAddress){
        if (userAddress != null){
            this.addressId = userAddress.getAddressId();
            this.consignee=userAddress.getConsignee();
            this.addressInfo = userAddress.getAddressInfo() ;
            this.addressHouse=userAddress.getAddressHouse();
            this.addressName = userAddress.getAddressName();
            this.addressPhone = userAddress.getAddressPhone();
            this.addressMark=userAddress.getAddressMark();
            this.sex = userAddress.getSex();
        }
    }
}
